
<body>

<div class="warp h">
    <!--header-->
    <header class="hd br">
    <?php if(! isset($dataFromGet)): ?>
        <a href="<?php echo $base_url; ?>home/account/myInfo" class="l-icon only-icon">
    <?php else:?>
        <a href="<?php echo $base_url; ?>home/order/submitorder?data=<?php echo urlencode($dataFromGet);?>" class="l-icon only-icon">
    <?php endif;?>
            <i class="iconfont icon-left1"></i>
        </a>
        <p class="tit2">
            <?php echo $title; ?>
        </p>

    </header>

    <?php foreach ($content as $value) : ?>
        <div class="order-address admin">

                <div class="l default" data-id="<?php echo $value['address_id']?>">
                    <i class="iconfont myicon <?php echo $value['default'] ? 'icon-gou' : '' ?>"></i>
                </div>
            <a href="<?php echo $base_url; ?>home/address/edit/<?php echo $value['address_id'];?><?php if(isset($dataFromGet)) echo '?data=' . urlencode($dataFromGet);?>">
                <div class="r">
                    <p><?php echo $value['consignee']; ?></p>
                    <p><?php echo $value['mobile']; ?></p>
                    <p><?php echo $value['province_text'] . $value['city_text'] . $value['district_text'] . $value['address']; ?></p>
                </div>
                <i class="icon iconfont icon-left"></i>
            </a>
        </div>
    <?php endforeach; ?>

    <div class="addAddress-ft">
        <a href="<?php echo $base_url; ?>home/address/add<?php if(isset($dataFromGet)) echo '?data=' . urlencode($dataFromGet);?>">新增收货地址</a>
    </div>

    <div class="line-box"></div>
    <div class="pd-box"></div>

</div>

<script src="<?php echo $base_url; ?>static/dist/js/base.js"></script>
<script>
    // 矫正rem
    function correctrem() {
        var rem_full_width = $("<div id='rem-test' style='width:7.5rem'></div>").appendTo($('body')).width();
        var device_width = Math.min(document.documentElement.clientWidth, 640);
        if (rem_full_width !== device_width) {
            document.documentElement.style.fontSize = (device_width / 7.5) * (device_width / rem_full_width) + 'px';
        }
        $('#rem-test').remove();
    }
    correctrem();
    $(function () {
        $(".admin .l.default").hammer().bind("tap", function (ev) {
            var $this_i = $(this).find('.myicon');
            if (!$this_i.hasClass("icon-gou")) {
                $(".myicon ").removeClass("icon-gou");
                $this_i.addClass("icon-gou");
            }

        });
        $(".default").on('click',function(){
            var id = $(this).data('id')
            $.ajax({
                url: "<?php echo $base_url; ?>home/Users/addDefaultUserAddress/",
                data: {
                    address_id: id
                },
                dataType: 'json',
                type: 'POST',
                success: function (data) {
                    console.log(data);
                    if (data.result == 0) {
                        location.href = "<?php echo $base_url; ?>home/address<?php if(isset($dataFromGet)) echo '?data=' . urlencode($dataFromGet);?>";
                    } else {
                        alert(data.errmsg);
                    }
                }
            });
        })
    })
</script>

</body>

</html>
